class testTicker extends egret.DisplayObjectContainer{
	public constructor() {
		super();
		this.addEventListener(egret.Event.ADDED_TO_STAGE,this.onAddToStage,this);
	}

	private star:egret.Bitmap;
	private speed:number = 0.05;
	private timeOnEnterFrame = 0;
	private time:number = 0;

	private onAddToStage( event: egret.Event ){
		RES.addEventListener(RES.ResourceEvent.CONFIG_COMPLETE, this.configEvent, this);
		RES.loadConfig("/resource/testGrid.res.json","/resource/");
	}

	private configEvent( event: egret.Event ){
		RES.removeEventListener(RES.ResourceEvent.CONFIG_COMPLETE, this.configEvent, this);
		RES.getResByUrl('/resource/assets/Test/star.png',this.onLoad,this,RES.ResourceItem.TYPE_IMAGE);
	}

	private async onLoad(event: any){
		var star: egret.Bitmap = new egret.Bitmap(event);
		this.addChild(star);
		this.star = star;

		this.time = egret.getTimer();
        egret.startTick(this.moveStar,this);
	}

	private onEnterFrame(e: egret.Event){
		var now = egret.getTimer();
		var time = this.timeOnEnterFrame;

		var pass = now - time;
		this.star.x += this.speed*pass;
		this.timeOnEnterFrame = egret.getTimer();

		if(this.star.x > 300)
		{
			this.removeEventListener(egret.Event.ENTER_FRAME,this.onEnterFrame,this)
		}
	}

	private moveStar(timeStamp:number):boolean {
        var now = timeStamp;
    var time = this.time;
    var pass = now - time;
    this.star.x += this.speed * pass;
    if(this.star.x > 300)
        egret.stopTick(this.moveStar,this);
    this.time = now;
    return false;
    }
}